#ifndef __PLATFORM_DIFF_H__
#define __PLATFORM_DIFF_H__

#include <limits.h>
#include "CommonDef.h"

EXTERN_C_BEGIN

#ifndef __WORDSIZE
  //Assume 32
  #define __WORDSIZE 32
#endif


#if defined(LINUX)
	#ifndef uint8_t
	typedef unsigned char  uint8_t;
	#endif
	#ifndef int8_t
	typedef signed char  int8_t;
	#endif
	#ifndef uint16_t
	 typedef unsigned short uint16_t;
	#endif
	#ifndef int16_t
	typedef signed short    int16_t;
	#endif
	#ifndef uint32_t
	typedef unsigned int uint32_t;
	#endif
	#ifndef int32_t
	typedef signed int    int32_t;
	#endif
#endif

#ifdef WIN32
    typedef unsigned char  uint8_t;
    typedef signed char    int8_t;
    typedef unsigned short uint16_t;
    typedef signed short   int16_t;
    typedef unsigned int   uint32_t;
    typedef signed int     int32_t;
#endif



#if defined(WIN32)
    typedef unsigned long long int uint64_t;
    typedef long long int          int64_t;
#elif (__WORDSIZE == 32)
    __extension__
    typedef long long int          int64_t;
    __extension__
    typedef unsigned long long int uint64_t;
#elif (__WORDSIZE == 64)
    typedef unsigned long int uint64_t;
    typedef long int          int64_t;
#endif

#ifdef WIN32
  #define UINT8_MAX  (UCHAR_MAX)
  #define UINT16_MAX (USHRT_MAX)
  #define UINT32_MAX (ULONG_MAX)

  #if __WORDSIZE == 64
    #define SIZE_MAX (18446744073709551615UL)
  #else
    #ifndef SIZE_MAX
    #define SIZE_MAX (4294967295U)
  #endif
  #endif
#endif

#ifdef WIN32
	typedef SSIZE_T  ssize_t;
#endif


#ifndef htonll
	#ifdef BIG_ENDIAN
	#define htonll(x)   (x)
	#define ntohll(x)   (x)
	#else
	#define htonll(x)   ((((uint64_t)htonl(x)) << 32) + htonl(x >> 32))
	#define ntohll(x)   ((((uint64_t)ntohl(x)) << 32) + ntohl(x >> 32))
	#endif
#endif

#if defined(WIN32)
  #define SNPRINTF _snprintf
  #define PRINTF   printf
  #define VPRINTF  vprintf
  #define FPRINTF  fprintf
#else 
  #define SNPRINTF snprintf
  #define PRINTF   printf
  #define VPRINTF  vprintf
  #define FPRINTF  fprintf
#endif

#ifdef WIN32
	typedef char bool; 
	#define true 1
	#define false 0
#else
#include <stdbool.h>
#endif

#ifdef WIN32
	#ifdef _USRDLL
		#ifdef DLL_API		
		#else
		#define DLL_API __declspec(dllimport)
		#endif
	#else
		#define DLL_API
	#endif
#else
	#define DLL_API
#endif


EXTERN_C_END

#endif 
